package com.bank.exception;

import org.apache.log4j.Logger;

import com.bank.code.RespCode;

public class CommonException extends Exception{
	
	Logger logger = Logger.getLogger(CommonException.class);
private static final long serialVersionUID = 3260964335893230172L;
	
	private RespCode respCode;
	
	private String code;
	private String message;
	
	public CommonException() {
	}

	public CommonException(String msg, Throwable th) {
		super(msg, th);
	}
	
	public CommonException(String msg) {
		super(msg);
	}
	
	public CommonException(RespCode respCode) {
		super();
		this.respCode = respCode;
		this.code = respCode.getRespCode();
		this.message = respCode.getMessage();
	}
	
	public CommonException(RespCode respCode, Throwable th) {
		super(respCode.getMessage(), th);
		this.respCode = respCode;
		this.code = this.respCode.getRespCode();
		this.message = this.respCode.getMessage();
	}
	
	public CommonException(RespCode respCode, Exception e) {
		super(respCode.getMessage(), e);
		this.respCode = respCode;
		this.code = this.respCode.getRespCode();
		this.message = this.respCode.getMessage();
	}
	
	public CommonException(RespCode respCode, String msg) {
		super(msg);
		this.respCode = respCode;
		this.code = this.respCode.getRespCode();
		if(msg==null)
			this.message = this.respCode.getMessage();
		else
			this.message = msg;
		logger.debug("CommonException:"+this.code);
	}
	
	public CommonException(RespCode respCode, String msg, Exception e) {
		super(msg, e);
		this.respCode = respCode;
		this.code = this.respCode.getRespCode();
		this.message = msg;
	}

	public String getRespCode() {
		return code;
	}

	public void setRespCode(String code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	
}
